<template>
  <div>

    <el-form ref="form" label-width="80px">
      <el-form-item label="链接">
        <el-input v-model="httpPath"></el-input>
      </el-form-item>
      <el-form-item label="提取码">
        <el-input v-model="extract"></el-input>
      </el-form-item>
      <el-form-item label="有效期">
        <el-radio-group v-model="effectiveTime">
          <el-radio :label="1">1天</el-radio>
          <el-radio :label="7">7天</el-radio>
          <el-radio :label="14">14天</el-radio>
          <el-radio :label="30">30天</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">创建链接</el-button>
        <el-button  @click="closeDialog">退出</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { addShare } from "@/api/resource/share";

export default {
  name: "AddShareEdit",
  props: ["fileId"],
  data(){
    return{
      form:{},
      effectiveTime: 0,
      httpPath: '',
      extract: ''
    }
  },
  methods: {
    onSubmit() {
      addShare({fileId: this.fileId,power:this.effectiveTime}).then(response => {

        console.log(response.data.httpPath)
        this.httpPath = response.data.httpPath;
        this.extract = response.data.extract;
      });

    },
    closeDialog() {
      this.$emit("close-dialog",false)
    }
  },
}
</script>

<style scoped>

</style>
